package com.shipwe.loans.ui.adapter

import android.view.View
import androidx.recyclerview.widget.RecyclerView
import com.shipwe.adapter.ShipweRecyclerViewAdapter
import com.shipwe.adapter.ShipweViewHolderHelper
import com.shipwe.loans.R
import org.json.JSONObject

/**
 * Shipwe
 * @Author wwdeng
 * @CreateTime: 2024/11/28 10:55
 * @Annotation：主页Tab
 */
class MainTabAdapter(recyclerView: RecyclerView?) : ShipweRecyclerViewAdapter<JSONObject>(recyclerView, R.layout.activity_main_tab_item) {

    override fun setItemChildListener(helper: ShipweViewHolderHelper, viewType: Int) {
        helper.setItemChildClickListener(R.id.mainTabItem)
    }

    override fun fillData(helper: ShipweViewHolderHelper, position: Int, model: JSONObject) {
        val mainTabIcon = helper.getImageView(R.id.mainTabIcon)
        mainTabIcon.setImageResource(model.optInt("mainTabIcon"))
        helper.setText(R.id.mainTabTitle,model.optString("mainTabTitle"))
        when(model.optBoolean("isSelect", false)){
            true -> {
                mainTabIcon.visibility = View.GONE
                helper.setVisibility(R.id.mainTabSelect,View.VISIBLE)
            }
            else -> {
                mainTabIcon.visibility = View.VISIBLE
                helper.setVisibility(R.id.mainTabSelect,View.GONE)
            }
        }
    }
}